//
//  XHBrokenLine.h
//  DrawTool
//
//  Created by sos on 16/3/9.
//  Copyright © 2016年 li_yong. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

#define MARGIN_LEFT 35              //统计图的左间隔
#define MARGIN_TOP 30               //统计图的顶部间隔
#define MARGIN_BETWEEN_X_POINT 50   //X轴的坐标点的间距
#define Y_SECTION 5                 //纵坐标轴的区间数

typedef enum
{
    LineChartViewType,  //折线图
    BarChartViewType,   //柱状图
    PieChartViewType    //饼状图
}ChartViewType;


@interface XHBrokenLine : UIView
//图形类型
@property (assign, nonatomic) ChartViewType chartViewType;

//是否动态绘制
@property (assign, nonatomic) BOOL isAnimation;

/**
 *  @author li_yong
 *
 *  构造方法
 *
 *  @param frame      frame
 *  @param dataSource 数据源
 *  @param type       绘图类型
 *  @isAnimation      是否动态绘制
 *
 *  @return
 */
- (id)initWithFrame:(CGRect)frame
     withDataSource:(NSMutableArray *)dataSource
           withType:(ChartViewType)type
      withAnimation:(BOOL)isAnimation;

+(UIView *)drawTool:(UIView *)view dataArr:(NSArray *)dataArr chartViewType:(ChartViewType)type color:(UIColor *)color;
@end


#pragma BaseChartView

@interface BaseChartView : UIView

@property (strong, nonatomic) NSMutableArray *dataSource;

//纵坐标上标记点的间距(即虚线的间距)
@property (assign, nonatomic) CGFloat dashedSpace;
//纵坐标最大值
@property (assign, nonatomic) int maxYValue;
//纵坐标的数值间隔(显示出来的坐标值的间隔)
@property (assign, nonatomic) int yNumberSpace;

/**
 *  @author li_yong
 *
 *  构造函数
 *
 *  @param dataSource 数据源
 *
 *  @return
 */
- (id)initWithDataSource:(NSMutableArray *)dataSource;

@end

#pragma CoordinateItem

@interface CoordinateItem : NSObject

//X坐标值
@property (copy, nonatomic) NSString *coordinateXValue;
//Y坐标值
@property (copy, nonatomic) NSString *coordinateYValue;
//颜色(主要用于绘制扇形图，区分数据)
@property (strong, nonatomic) UIColor *itemColor;

/**
 *  @author li_yong
 *
 *  构造函数
 *
 *  @param xValue X坐标值
 *  @param yValue Y坐标值
 *
 *  @return
 */
- (id)initWithXValue:(NSString *)xValue withYValue:(NSString *)yValue;

/**
 *  @author li_yong
 *
 *  构造函数
 *
 *  @param xValue    X坐标值
 *  @param yValue    Y坐标值
 *  @param itemColor item的颜色
 *
 *  @return
 */
- (id)initWithXValue:(NSString *)xValue
          withYValue:(NSString *)yValue
           withColor:(UIColor *)itemColor;

@end


#pragma LineChartView

@interface LineChartView : BaseChartView

/**
 *  @author li_yong
 *
 *  构建方法
 *
 *  @param dataSource  数据源
 *  @param color       折线点和折线的颜色
 *  @param isAnimation 是否动态绘制
 *
 *  @return
 */
- (id)initWithDataSource:(NSMutableArray *)dataSource
   withLineAndPointColor:(UIColor *)color
           withAnimation:(BOOL)isAnimation;

@end

#pragma BarChartView

@interface BarChartView : BaseChartView

/**
 *  @author li_yong
 *
 *  构建方法
 *
 *  @param dataSource  数据源
 *  @param color       折线点和折线的颜色
 *  @param isAnimation 是否动态绘制
 *
 *  @return
 */
- (id)initWithDataSource:(NSMutableArray *)dataSource
               withColor:(UIColor *)color
           withAnimation:(BOOL)isAnimation;


@end

#pragma PieChartView

@interface PieChartView : UIView

//饼状图的大小
@property (assign, nonatomic) CGFloat pieRadius;

/**
 *  @author li_yong
 *
 *  构建函数
 *
 *  @param dataSource  数据源
 *  @param isAnimation 是否使用动画绘制
 *
 *  @return
 */
- (id)initWithDataSource:(NSMutableArray *)dataSource withAimation:(BOOL)isAnimation;

@end



